const plugin = requirePlugin("QCloudAIVoice");
let resultText = '';

let innerAudioContext = wx.createInnerAudioContext();
// let recorderManager = plugin.getRecordRecognitionManager()
let recorderManager = plugin.speechRecognizerManager();


// 开始识别
recorderManager.OnRecognitionStart = (res) => {
	console.log('开始识别', res);


};
// 一句话开始
recorderManager.OnSentenceBegin = (res) => {
	console.log('一句话开始', res);
};
// 识别变化时
recorderManager.OnRecognitionResultChange = (res) => {
	console.log('识别变化时', res);

};
// 一句话结束
recorderManager.OnSentenceEnd = (res) => {
	console.log('一句话结束', res);
	resultText += res.result.voice_text_str;
	console.log("resultText ------》》》", resultText)
};
// 识别结束
recorderManager.OnRecognitionComplete = (res) => {
	console.log('识别结束', res);
};
// 识别错误
recorderManager.OnError = (res) => {
	console.log(res);
	
};
recorderManager.OnRecorderStop = () => {
	console.log('超过录音时长');
};



// recorderManager.onStart = function(res) {
// 	console.log("成功开始录音识别", res)
// }

// recorderManager.onStop = function(res) {
// 	debugger
// 	innerAudioContext.src = res.tempFilePath;
// 	innerAudioContext.play();
// 	console.log("record file path", res.tempFilePath)
// 	console.log("result", res.result)
// }

// recorderManager.onError = function(res) {
//     console.error("error msg", res.msg)
// }

// recorderManager.start({duration:30000, lang: "zh_CN"})

export default recorderManager;